﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Mvc;
using BackendDeveloper_WS.Services;
using BackendDeveloper_WS.Models;

namespace BackendDeveloper_WS.Controllers
{
    public class CommentsController : ApiController
    {
        // GET api/Comments/5
        public IEnumerable<Comment> GetComments(int id)
        {
            OrderServices os = new OrderServices();
            return os.getComments(id);
        }

        // POST api/Comments
        public HttpResponseMessage PostComment(Comment comment) //[FromBody]
        {
            OrderServices os = new OrderServices();
            if (!os.createNewComment(comment.orderId, comment.message))
            {
                return new HttpResponseMessage(HttpStatusCode.InternalServerError);
            }
            else {
                return new HttpResponseMessage(HttpStatusCode.OK);
            }
        }
    }
}
